package com.zwan.oam_rtc.utils.process;

import java.io.File;
import java.io.IOException;

public class ProcessThread extends Thread {
    private String command;
    private String workDir;
    StreamGobbler errorGobbler;
    StreamGobbler outputGobbler;



    public void run(){
        Process proc = null;
        try {
            proc = Runtime.getRuntime().exec(command, null , new File(workDir));
        } catch (IOException e) {
            e.printStackTrace();
        }
        errorGobbler = new StreamGobbler(proc.getErrorStream(), "Error");
        outputGobbler = new StreamGobbler(proc.getInputStream(), "Output");
        errorGobbler.start();
        outputGobbler.start();
        try {
            proc.waitFor();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


    public String getCommand() {
        return command;
    }

    public void setCommand(String command) {
        this.command = command;
    }

    public String getWorkDir() {
        return workDir;
    }

    public void setWorkDir(String workDir) {
        this.workDir = workDir;
    }
}
